package com.foreknow.demo24;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Jdbc对数据库进行DML操作
 */
public class DMLDemo {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/demodb?useUnicode=true&characterEncoding=utf8&useSSL=false", "root", "root");
            Statement statement = connection.createStatement();
            //向数据库添加信息
       //   int isRigth = statement.executeUpdate("insert into emp(empno,ename,job) values(9999,'fender123','music')");
            //删除信息
            int isRigth = statement.executeUpdate("delete from emp where empno=9999");
            System.out.println(isRigth);
            statement.close();
            connection.close();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}